package com.shell.customer.accreditation.rx;

import org.springframework.stereotype.Component;

import com.shell.bee.base.utils.SpringContextUtil;
import com.shell.bee.file.utils.FileHelper;
import com.shell.customer.accreditation.AccreditEvent;
import com.shell.customer.accreditation.vo.AccreditationVo;
import com.shell.customer.po.CusRec;
import com.shell.framework.rx.OnErrorNotImplementedSubscriber;
import com.shell.framework.utils.CommonDataUtil;

@Component
public class SetFilesSubscriber extends OnErrorNotImplementedSubscriber<AccreditEvent> {
	public void onApplicationEvent(AccreditEvent event) {
		AccreditationVo accreditationVo = event.getAccreditationVo();
		CusRec cus = accreditationVo.getCustomerC();
		String cusType = CommonDataUtil.getCurEnt().getCusType();
		if (!"FINNER".equals(cusType)) {
			FileHelper.setRelateId(accreditationVo.getBankCertificate(), cus.getCusId(), "3");
			FileHelper.setRelateId(accreditationVo.getCompanyCertificate(), cus.getCusId(), "0");
			FileHelper.setRelateId(accreditationVo.getLegalCertificate(), cus.getCusId(), "1");
			if ("on".equals(SpringContextUtil.getProperty("contract.switch"))) {
				FileHelper.setRelateId(accreditationVo.getContractOpen(), cus.getCusId(), "7");
				FileHelper.setRelateId(accreditationVo.getContractAuth(), cus.getCusId(), "8");
			}
		}
	}
}
